﻿<UserControl x:Class="YoderZone.Extensions.Options.Controls.PopupColorPicker"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:viewModel1="clr-namespace:YoderZone.Extensions.Options.ViewModel"
             xmlns:controls1="clr-namespace:YoderZone.Extensions.Options.Controls"
             d:DesignHeight="23"
             d:DesignWidth="100"
             mc:Ignorable="d">
    <UserControl.Resources>
        <viewModel1:ColorToBrushConverter x:Key="ColorToBrushConverter" />
    </UserControl.Resources>
    <Grid>
        <Rectangle HorizontalAlignment="Stretch"
                   VerticalAlignment="Stretch"
                   Fill="{Binding RelativeSource={RelativeSource FindAncestor,
                                                                 AncestorType={x:Type controls1:PopupColorPicker}},
                                  Converter={StaticResource ColorToBrushConverter},
                                  Path=ColorSwath}" />
        <Popup x:Name="Popup"
               StaysOpen="True"
               IsOpen="{Binding IsOpen, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type controls1:PopupColorPicker}}}">
            <Border Background="WhiteSmoke"
                    BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
                    BorderThickness="1"
                    Padding="1">
                <Border Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"
                        BorderBrush="{DynamicResource {x:Static SystemColors.ActiveBorderBrushKey}}"
                        BorderThickness="1">
                    <controls1:ColorPicker Width="300"
                                          ColorSwath="{Binding ColorSwath,
                                                               Mode=TwoWay,
                                                               RelativeSource={RelativeSource FindAncestor,
                                                                                              AncestorType={x:Type controls1:PopupColorPicker}}}"
                                          Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrush}}"
                                          Padding="4,0" />
                </Border>
            </Border>
        </Popup>
    </Grid>
</UserControl>
